package com.xidian.zhiancloud.controller.luling;
import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.model.RiskLedgerStatus;
import com.xidian.zhiancloud.service.luling.RiskLedgerStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import java.util.Date;
import java.util.List;
/**
 **风险台账接口
 * @Author:luling
 * @Date:2021/1/7   15:24
 */
@RestController
@RequestMapping("/RiskLedgerStatus")
public class RiskLedgerStatusController {
    @Autowired
    private RiskLedgerStatusService riskLedgerStatusService;
    /**
     * 根据id获取风险台账信息
     *
     * @param id 风险台账对象的id
     * @return  返回风险台账对象
     */
    @PutMapping("/updateByIds")
    public ResultDTO<Object>updateByIds(List<RiskLedgerStatus> riskLedgerStatusList) {
        riskLedgerStatusService.updateByIds(riskLedgerStatusList);
        return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
    }
    /**
     * 列表查询
     *
     * @param  controlLevel 管控层级
     * @param riskType 风险点类型
     * @param  riskName  风险点名称
     * @param itemName 检查项目名称
     * @param itemStandard 检查标准
     * @param itemSituation 不符合标准情况
     * @param levelEval 评价等级
     *@param levelRisk 风险级别
     * @param levelProp 建议措施风险级别
     * @param controlTech  工程技术
     * @param controlStep 管理措施
     * @param controlEdu 培训教育
     * @param controlProtec 个体防护
     * @param controlEmerg 应急处理
     * @param locale 区域/位置
     * @param eval  评价方法
     * @param riskValue 风险值
     * @param riskColor  风险色
     * @param time  辨识评价时间
     * @param unit  责任单位
     * @param personLiable 责任人
     * @param   key    关键字
     * @param current   分页偏移量
     * @param size    每一页的数量
     * @return 返回设施设备列表
     **/
    @GetMapping("/getList")
    public ResultDTO<Object> getList(@RequestParam(value = "controlLevel", required = false) String controlLevel,
                             @RequestParam(value = "riskType", required = false) String riskType,
                             @RequestParam(value = "riskName", required = false) String riskName,
                             @RequestParam(value = "itemName", required = false) String itemName,
                             @RequestParam(value = "itemStandard", required = true) String itemStandard,
                             @RequestParam(value = "itemSituation", required = true) String itemSituation,
                             @RequestParam(value = "levelEval", required = true) String levelEval,
                             @RequestParam(value = "levelRisk", required = true) String levelRisk,
                             @RequestParam(value = "levelProp", required = false) String levelProp,
                             @RequestParam(value = "controlTech", required = false) String controlTech,
                             @RequestParam(value = "controlStep", required = false) String controlStep,
                             @RequestParam(value = "controlEdu", required = false) String controlEdu,
                             @RequestParam(value = "controlProtec", required = false) String controlProtec,
                             @RequestParam(value = "controlEmerg", required = false) String controlEmerg,
                             @RequestParam(value = "locale", required = false) String locale,
                             @RequestParam(value = "eval", required = false) String eval,
                             @RequestParam(value = "riskValue", required = false) String riskValue,
                             @RequestParam(value = "riskColor", required = false) String riskColor,
                            @RequestParam(value = "time", required = false) String time,
                             @RequestParam(value = "unit", required = false) String unit,
                             @RequestParam(value = "personLiable", required = false) String personLiable,
                             @RequestParam(value = "current", required = true) int current,
                             @RequestParam(value = "size", required = true) int size) {
        return ResultDTO.successOf(riskLedgerStatusService.getList(controlLevel, riskType, riskName, itemName, itemStandard, itemSituation, levelEval, levelRisk, levelProp, controlTech,
                controlStep, controlEdu, controlProtec, controlEmerg, locale, eval, riskValue, riskColor,time,unit,personLiable,current,size), GeneralResponseEnums.SUCCESS);

    }

    /**
     * 修改风险台账信息
     * @param  craftNodeStatus  修改风险台账对象
     * @return ResultDTO对象
     */
    @PostMapping("/singleupdate")
    public ResultDTO<Boolean> singleupdate(@RequestBody RiskLedgerStatus riskLedgerStatus) {
        riskLedgerStatusService.singleupdate(riskLedgerStatus);
        return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
    }
}
